import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    // {
    //   path: '/',
    //   name: 'Home',
    //   component: Home
    // },
    {
        path: '/login',
        name: 'Login',
        component: () =>
            import ('../views/Login/index.vue') // 路由懒加载  注释表示打包分类
    },
    {
        path: '/reg',
        name: 'register',
        component: () =>
            import ('../views/Reg/index.vue') // 路由懒加载  注释表示打包分类
    },

    /* 首页入口 */
    /*
    如果二级路由写了 /  就不需要根据一级路由来查找
    如果二级路由没有写 /  需要根据一级路由来进行拼接查找
     */
    {
        path: '/',
        component: () =>
            import ('../views/layout/index.vue'),
        children: [{
                path: '',
                component: () =>
                    import ('../views/Home/index.vue')
            },
            {
                path: 'artCategory',
                component: () =>
                    import ('../views/art/artCategory.vue')
            },
            {
                path: 'artList',
                component: () =>
                    import ('../views/art/artList.vue')
            },
            {
                path: 'userInfo',
                component: () =>
                    import ('../views/user/userInfo.vue')
            },
            {
                path: 'changeAvatar',
                component: () =>
                    import ('../views/user/changeAvatar.vue')
            },
            {
                path: 'resetPwd',
                component: () =>
                    import ('../views/user/resetPwd.vue')
            }
        ]
    }
]

const router = new VueRouter({
    routes
})

export default router